package com.sunwayhorizo.health.platform.security.persistent;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.sunwayhorizo.health.platform.util.BeanHelper;

@Entity
@TableGenerator(name = "SecurityDataObject_IdGenerator", table = "ET_Id_Generator", pkColumnName = "pkColumn", valueColumnName = "valueColumn", pkColumnValue = "SECURITY_DATA_OBJECT_ID",allocationSize=1)
@Table(name = "SECURITY_DATA_OBJECT", schema = "ETS")
public class SecurityDataObject implements java.io.Serializable {
	
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "SecurityDataObject_IdGenerator")
	@Column(name = "DATA_OBJECT_ID", unique = true, nullable = false, length = 32)
	private String dataObjectId;
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE})
	@JoinColumn(name = "DATA_TYPE_ID")
	private SecurityDataType dataType;
	
	@Column(name = "DATA_OBJECT_NAME", length = 30)
	private String dataObjectName;
	
	@Column(name = "DATA_OBJECT_CODE", length = 30)
	private String dataObjectCode;
	
	@Column(name = "CREATOR_NAME", length = 30)
	private String creatorName;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "CREATE_TIME", length = 7)
	private Date createTime;
	
	@Column(name = "MODIFIER_NAME", length = 30)
	private String modifierName;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "MODIFY_TIME", length = 7)
	private Date modifyTime;
	
	@Column(name = "REMARK", length = 200)
	private String remark;
	
	@OneToMany(mappedBy = "dataObject",fetch = FetchType.LAZY,cascade = CascadeType.ALL)
	private List<SecurityDataObjectAccount> dataObjectAccounts = new ArrayList<SecurityDataObjectAccount>(
			0);

	public SecurityDataObject() {
	}

	public SecurityDataObject(String dataObjectId) {
		this.dataObjectId = dataObjectId;
	}

	public SecurityDataObject(String dataObjectId,
			SecurityDataType dataType, String dataObjectName,
			String dataObjectCode, String creatorName, Date createTime,
			String modifierName, Date modifyTime, String remark,
			List<SecurityDataObjectAccount> dataObjectAccounts) {
		this.dataObjectId = dataObjectId;
		this.dataType = dataType;
		this.dataObjectName = dataObjectName;
		this.dataObjectCode = dataObjectCode;
		this.creatorName = creatorName;
		this.createTime = createTime;
		this.modifierName = modifierName;
		this.modifyTime = modifyTime;
		this.remark = remark;
		this.dataObjectAccounts = dataObjectAccounts;
	}

	public String getDataObjectId() {
		return this.dataObjectId;
	}

	public void setDataObjectId(String dataObjectId) {
		this.dataObjectId = dataObjectId;
	}

	public SecurityDataType getDataType() {
		return this.dataType;
	}

	public void setDataType(SecurityDataType dataType) {
		this.dataType = dataType;
	}

	public String getDataObjectName() {
		return this.dataObjectName;
	}

	public void setDataObjectName(String dataObjectName) {
		this.dataObjectName = dataObjectName;
	}

	public String getDataObjectCode() {
		return this.dataObjectCode;
	}

	public void setDataObjectCode(String dataObjectCode) {
		this.dataObjectCode = dataObjectCode;
	}

	public String getCreatorName() {
		return this.creatorName;
	}

	public void setCreatorName(String creatorName) {
		this.creatorName = creatorName;
	}

	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getModifierName() {
		return this.modifierName;
	}

	public void setModifierName(String modifierName) {
		this.modifierName = modifierName;
	}

	public Date getModifyTime() {
		return this.modifyTime;
	}

	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public List<SecurityDataObjectAccount> getDataObjectAccounts() {
		return this.dataObjectAccounts;
	}

	public void setDataObjectAccounts(
			List<SecurityDataObjectAccount> dataObjectAccounts) {
		this.dataObjectAccounts = dataObjectAccounts;
	}
	
	@Override
	public String toString() {
		return BeanHelper.toString(this);
	}
}
